/**
* Casey Burkhardt
* CSC 2035 - Algorithms and Data Structures III
* Due: 09/02/2008
* Passenger.java - Manages Passenger Objects for the Airport Security Project.
*/

public class Passenger implements Comparable
{
	
	private String name;
	private double arrivalTime, departureTime;
	private int reservationNumber;
	
	/**
	 * @param name
	 * @param reservationNumber
	 */
	public Passenger(String name, int reservationNumber, double arrivalTime)
	{
		this.name = name;
		this.reservationNumber = reservationNumber;
		this.arrivalTime = arrivalTime;
		this.departureTime = 00.00;
	}

	/**
	 * @return the name
	 */
	public String getName()
	{
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name)
	{
		this.name = name;
	}

	/**
	 * @return the arrivalTime
	 */
	public double getArrivalTime()
	{
		return arrivalTime;
	}

	/**
	 * @param arrivalTime the arrivalTime to set
	 */
	public void setArrivalTime(double arrivalTime)
	{
		this.arrivalTime = arrivalTime;
	}

	/**
	 * @return the departureTime
	 */
	public double getDepartureTime()
	{
		return departureTime;
	}

	/**
	 * @param departureTime the departureTime to set
	 */
	public void setDepartureTime(double departureTime)
	{
		this.departureTime = departureTime;
	}

	/**
	 * @return the reservationNumber
	 */
	public int getReservationNumber()
	{
		return reservationNumber;
	}

	/**
	 * @param reservationNumber the reservationNumber to set
	 */
	public void setReservationNumber(int reservationNumber)
	{
		this.reservationNumber = reservationNumber;
	}
	
	public String toString()
	{
		String output = "Passenger Information:\nName: " + name + "\nReservation Number: " + reservationNumber + "\nArrival Time: " + arrivalTime + "\nDeparture Time: " + departureTime;
		return output;
	}
	
	public boolean equals(Passenger other)
	{
		if((this.name.equals(other.name)) && (this.reservationNumber == other.reservationNumber))
			return true;
		else
			return false;			
	}
	
	public int compareTo(Object compare_in)
	{
	
		Passenger compare = (Passenger)compare_in;
		
		// Returns -1 if compared object has lower reservation number. 
		if(this.reservationNumber > compare.reservationNumber)
			return -1;
		
		// Returns 0 if compared object has same reservation number.
		// (This should never happen)
		else if(this.reservationNumber == compare.reservationNumber)
			return 0;

		// Returns 1 if compared object has higher reservation number. 
		else
			return 1;
	}
}